import time
from common.unit import AndroidUI
from case.lnitial.lnitial_page import LnitialTest


# from appium.webdriver.common.touch_action import TouchAction

# 首页按钮
class HomePageObject:

    def __init__(self):
        self.driver = AndroidUI.get_webdriver()
        # AndroidUI.scan(AndroidUI().cleaner)

    # 返回按钮
    def back_button(self):
        self.driver.keyevent(4)

    # 首页标题
    def home_page(self):
        element = self.driver.find_element_by_android_uiautomator('new UiSelector().text("首页")')
        return element

    # 回收按钮
    def recover_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/tvRecover")
        return element

    # 入库按钮
    def enter_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/tvEnterLib")
        return element

    # 追溯按钮
    def check_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/tvAbnormal")
        return element

    # 出库按钮
    def out_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/tvOutLib")
        return element

    # 帮助按钮
    def help_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/tvHelp")
        return element

    # 云同步/注销按钮
    def exite_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/tvExite")
        return element


if __name__ == '__main__':
    s = HomePageObject()
    a = AndroidUI()
    AndroidUI.scan(a.cleaner)
    s.recover_button().click()
    s.back_button()

    s.enter_button().click()
    s.back_button()

    s.out_button().click()
    s.back_button()

    s.check_button().click()
    s.back_button()

    s.exite_button().click()
